package source;

import org.apache.xmlrpc.server.PropertyHandlerMapping;
import org.apache.xmlrpc.server.XmlRpcServer;
import org.apache.xmlrpc.server.XmlRpcServerConfigImpl;
import org.apache.xmlrpc.webserver.WebServer;

class XmlRpc 
{
	private WebServer webServer;
	
	// a solo scopo di test
	public static void main(String[] args)
	{
		try 
		{
			XmlRpc server = new XmlRpc();
			server.start();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}
	
	public XmlRpc() throws Exception
	{
        webServer = new WebServer(8080);
        XmlRpcServer xmlRpcServer = webServer.getXmlRpcServer();
        PropertyHandlerMapping phm = new PropertyHandlerMapping();
        
        // Interfaccia ed implementazione
        phm.addHandler("Request", new RequestImpl().getClass());
        
        xmlRpcServer.setHandlerMapping(phm);
        XmlRpcServerConfigImpl serverConfig = (XmlRpcServerConfigImpl) xmlRpcServer.getConfig();
        serverConfig.setEnabledForExtensions(true);
        serverConfig.setContentLengthOptional(false);
	}
	
	public void start() throws Exception
	{
		webServer.start();
	}
}
